<?php

namespace app\admin\validate;

use app\common\Validate;

class MenuValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        "name" => ["require", 'length' => '2,6'],
        "is_menu" => ["require"],
        "controller" => ["requireIf" => "is_menu,1"],
        "method" => ["requireIf" => "is_menu,1"],
        "remark" => ["length" => "2,50"]
    ];
    /**
     * 提示消息
     */
    protected $message = [
        "name.require" => "名称必须",
        "name.length" => "名称长度必须2~6个字符",
        "controller.requireIf" => "父级组必须",
        "method.requireIf" => "子页面必须",
        "remark.length" => "备注必须2~50个字符"
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', "is_menu", "controller", "method", "remark"],
        'edit' => ['name', "is_menu", "controller", "method", "remark"],
    ];
}
